#define _CRT_SECURE_NO_WARNINGS 
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	vector<int>tree;
	int n, m, longest = 0, shortest = 0, cut, height;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int x;	cin >> x;
		tree.push_back(x);
		if (x > longest) longest = x;
	}
	while (longest > shortest+1) {
		cut = 0;
		int mid = (longest + shortest) / 2;
		for (int i = 0; i < n; i++) {
			if (tree[i] > mid) cut += tree[i] - mid;
		}
		if (cut < m) {
			longest = (longest + shortest) / 2;
		}
		else if (cut == m) {
			height = mid; break;
		}
		else {
			shortest = (longest + shortest) / 2;
		}
	}
	if (longest == shortest + 1) {
		if (height < longest) height = shortest;
	}
	cout << height;
	return 0;
}